import { Injectable } from '@angular/core';
@Injectable()
export class UtilService {
  toFormData(data){
    const paraArr=[];
    for(const key in data){
      if(data[key] || data[key] === 0){
        paraArr.push([key,data[key]].join('='));

      }
    }

    return paraArr.join('&');
  }
    formatDate(date){
      if(date){
        return Date.parse(date);
      }else{
        return '';
      }
    }
  Trim1(str)
  {
    return str.replace(/(^\s*)|(\s*$)/g, "");
  }
  Trim(str,is_global)
  {
    let result;
    result = str.replace(/(^\s+)|(\s+$)/g,"");
    if(is_global.toLowerCase()=="g")
    {
      result = result.replace(/\s/g,"");
    }
    return result;
  }


  }


